<?php
require_once APP . '/application/controllers/FrontAction.php';
require_once APP . '/application/models/Publication.php';

/**
 * 出版信息
 */
class PublicationController extends FrontAction
{
    
	public function init()
	{
		$this->view->typename = "Publication";
	}
    /**
     * 首页
     *
     */
    public function indexAction()
    {
    	// empty
    }
    

    /**
     * 列表页面
     *
     */
    public function listAction()
    {
    	$id = (int)$_REQUEST['id'];
    	 
    	$nowp = intval($this->getParam("nowp", 1));
    	 
    	// 读取文章列表
    	$obj_pub = new Publication($this->db);
    	$result = $obj_pub->listPublicationByWhere("where typeid=" . $id, $nowp, 15);
    	 
    	$this->view->list = $result['list'];
    	$this->view->page = $result['page'];
    	$this->view->pagenum = Util::pageNumStyle($result['page']);

    	$this->view->typeid = $id;
    	$this->view->cname = $this->getParam("c");
    	$this->view->htitle = $this->view->typename;
    	
    	$this->render("list");
    }
    
    /**
     * 显示页面
     *
     */
    public function showAction()
    {
    	$id = (int)$_REQUEST['id'];
    	
    	$nowp = intval($this->getParam("nowp", 1));
    	
    	// 读取文章列表
    	$obj_pub = new Publication($this->db);
    	$arr_articleinfo = $obj_pub->show($id);
    	$cid = $arr_articleinfo['typeid'];
    	
    	$this->view->typeid = $cid;
    	$this->view->cname = $this->getParam("c");
    	$this->view->content = $arr_articleinfo;
    	$this->view->htitle = htmlspecialchars($arr_articleinfo['name']);

    	$this->render("show");
    }
}
